<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
// Regression test for crbug.com/685347
test(() => {
  assert_not_equals(
      window.eventSender, undefined, 'This test requires eventSender');

  assert_selection(
      '<iframe></iframe>',
      selection => {
        const document = selection.document;
        const iframe = document.querySelector('iframe');
        iframe.contentDocument.documentElement.contentEditable = true;
        iframe.contentDocument.documentElement.addEventListener(
            'focusout',
            () => iframe.parentNode.removeChild(iframe));
        iframe.contentDocument.documentElement.focus();
        eventSender.keyDown('Enter');
      },
      '');
}, 'Should not crash when inserting linebreak removes frame.');
</script>
